<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>UE4 RPC | Element</title><meta name="keywords" content="UnrealEngine"><meta name="author" content="FHang"><meta name="copyright" content="FHang"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><meta name="description" content="UE4 RPC1. RPC 架构1.1 架构简介 一个服务器， 一个或多个客户端 不能信任客户端，所有重要信息都需要通过服务器验证 Listen Server监听服务器和Dedicated Server专有服务器  1.2 基本GamePlay结构 Server GameMode 仅存在于Server GameState 同时存在与Server和Client Pawn_Server, Pawn_A">
<meta property="og:type" content="article">
<meta property="og:title" content="UE4 RPC">
<meta property="og:url" content="https://fhangh.gitee.io/article/7dd18469.html">
<meta property="og:site_name" content="Element">
<meta property="og:description" content="UE4 RPC1. RPC 架构1.1 架构简介 一个服务器， 一个或多个客户端 不能信任客户端，所有重要信息都需要通过服务器验证 Listen Server监听服务器和Dedicated Server专有服务器  1.2 基本GamePlay结构 Server GameMode 仅存在于Server GameState 同时存在与Server和Client Pawn_Server, Pawn_A">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_26.jpg">
<meta property="article:published_time" content="2022-05-19T04:30:00.826Z">
<meta property="article:modified_time" content="2022-05-19T04:30:28.043Z">
<meta property="article:author" content="FHang">
<meta property="article:tag" content="UnrealEngine">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_26.jpg"><link rel="shortcut icon" href="/fhangh/img/fh.png"><link rel="canonical" href="https://fhangh.gitee.io/article/7dd18469"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta name="yandex-verification" content="{&quot;theme_color&quot;:{&quot;enable&quot;:true,&quot;main&quot;:&quot;#49B1F5&quot;,&quot;paginator&quot;:&quot;#00c4b6&quot;,&quot;button_hover&quot;:&quot;#FF7242&quot;,&quot;text_selection&quot;:&quot;#00c4b6&quot;,&quot;link_color&quot;:&quot;#99a9bf&quot;,&quot;meta_color&quot;:&quot;#858585&quot;,&quot;hr_color&quot;:&quot;#A4D8FA&quot;,&quot;code_foreground&quot;:&quot;#F47466&quot;,&quot;code_background&quot;:&quot;rgba(27, 31, 35, .05)&quot;,&quot;toc_color&quot;:&quot;#00c4b6&quot;,&quot;blockquote_padding_color&quot;:&quot;#49b1f5&quot;,&quot;blockquote_background_color&quot;:&quot;#49b1f5&quot;}}"/><link rel="stylesheet" href="/fhangh/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css"><script>var GLOBAL_CONFIG = { 
  root: '/fhangh/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  ClickShowText: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"top-right"},
  justifiedGallery: {
    js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
    css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isanchor: false
};

var saveToLocal = {
  set: function setWithExpiry(key, value, ttl) {
    const now = new Date()
    const expiryDay = ttl * 86400000
    const item = {
      value: value,
      expiry: now.getTime() + expiryDay,
    }
    localStorage.setItem(key, JSON.stringify(item))
  },

  get: function getWithExpiry(key) {
    const itemStr = localStorage.getItem(key)

    if (!itemStr) {
      return undefined
    }
    const item = JSON.parse(itemStr)
    const now = new Date()

    if (now.getTime() > item.expiry) {
      localStorage.removeItem(key)
      return undefined
    }
    return item.value
  }
}</script><script id="config_change">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-05-19 12:30:28'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(function () {  window.activateDarkMode = function () {
    document.documentElement.setAttribute('data-theme', 'dark')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
    }
  }
  window.activateLightMode = function () {
    document.documentElement.setAttribute('data-theme', 'light')
   if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
    }
  }
  const autoChangeMode = 'false'
  const t = saveToLocal.get('theme')
  if (autoChangeMode === '1') {
    const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
    const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
    const isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
    const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
    if (t === undefined) {
      if (isLightMode) activateLightMode()
      else if (isDarkMode) activateDarkMode()
      else if (isNotSpecified || hasNoSupport) {
        const now = new Date()
        const hour = now.getHours()
        const isNight = hour <= 6 || hour >= 18
        isNight ? activateDarkMode() : activateLightMode()
      }
      window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
        if (saveToLocal.get('theme') === undefined) {
          e.matches ? activateDarkMode() : activateLightMode()
        }
      })
    } else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else if (autoChangeMode === '2') {
    const now = new Date()
    const hour = now.getHours()
    const isNight = hour <= 6 || hour >= 18
    if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
    else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else {
    if (t === 'dark') activateDarkMode()
    else if (t === 'light') activateLightMode()
  }const asideStatus = saveToLocal.get('aside-status')
if (asideStatus !== undefined) {
   if (asideStatus === 'hide') {
     document.documentElement.classList.add('hide-aside')
   } else {
     document.documentElement.classList.remove('hide-aside')
   }
}})()</script><meta name="generator" content="Hexo 5.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" data-lazy-src="/fhangh/img/fh.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/fhangh/archives/"><div class="headline">文章</div><div class="length-num">26</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/fhangh/tags/"><div class="headline">标签</div><div class="length-num">10</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/fhangh/categories/"><div class="headline">分类</div><div class="length-num">4</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/fhangh/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/fhangh/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/fhangh/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/fhangh/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/fhangh/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/fhangh/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 列表</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/fhangh/music/"><i class="fa-fw fas fa-music"></i><span> Music</span></a></li><li><a class="site-page" href="/fhangh/movies/"><i class="fa-fw fas fa-video"></i><span> Movie</span></a></li><li><a class="site-page" href="/fhangh/Gallery/"><i class="fa-fw fas fa-images"></i><span> Image</span></a></li></ul></div></div></div></div><div id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img/postImg_26.jpg)"><nav id="nav"><span id="blog_name"><a id="site-name" href="/fhangh/">Element</a></span><span id="menus"><div id="search_button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/fhangh/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/fhangh/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/fhangh/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/fhangh/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/fhangh/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/fhangh/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 列表</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/fhangh/music/"><i class="fa-fw fas fa-music"></i><span> Music</span></a></li><li><a class="site-page" href="/fhangh/movies/"><i class="fa-fw fas fa-video"></i><span> Movie</span></a></li><li><a class="site-page" href="/fhangh/Gallery/"><i class="fa-fw fas fa-images"></i><span> Image</span></a></li></ul></div></div><span class="close" id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></span></span></nav><div id="post-info"><h1 class="post-title">UE4 RPC</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-05-19T04:30:00.826Z" title="发表于 2022-05-19 12:30:00">2022-05-19</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-05-19T04:30:28.043Z" title="更新于 2022-05-19 12:30:28">2022-05-19</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/fhangh/categories/UnrealEngine/">UnrealEngine</a></span></div><div class="meta-secondline"> <span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.6k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>5分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="UE4-RPC"><a href="#UE4-RPC" class="headerlink" title="UE4 RPC"></a>UE4 RPC</h1><h3 id="1-RPC-架构"><a href="#1-RPC-架构" class="headerlink" title="1. RPC 架构"></a>1. RPC 架构</h3><h4 id="1-1-架构简介"><a href="#1-1-架构简介" class="headerlink" title="1.1 架构简介"></a>1.1 架构简介</h4><ul>
<li>一个服务器， 一个或多个客户端</li>
<li>不能信任客户端，所有重要信息都需要通过服务器验证</li>
<li><code>Listen Server</code>监听服务器和<code>Dedicated Server</code>专有服务器</li>
</ul>
<h4 id="1-2-基本GamePlay结构"><a href="#1-2-基本GamePlay结构" class="headerlink" title="1.2 基本GamePlay结构"></a>1.2 基本GamePlay结构</h4><ul>
<li><strong>Server</strong><ul>
<li><code>GameMode</code> 仅存在于Server</li>
<li><code>GameState</code> 同时存在与Server和Client</li>
<li><code>Pawn_Server</code>, <code>Pawn_A</code>, <code>Pawn_B</code> 同时存在与Server和Client</li>
<li><code>PlayerState_Server</code>, <code>PlayerState_A</code>, <code>PlayerState_B</code> 同时存在与Server和Client</li>
<li><code>PlayerController_Server</code> 仅存在于Server</li>
<li><code>PlayerController_A</code>, <code>PlayerController_B</code> 同时存在与Server和各自所拥有的Client</li>
<li><code>GameInstance</code>, <code>UI</code> 同时存在与Server和各自所拥有的Client</li>
</ul>
</li>
<li><strong>Client</strong><ul>
<li>每个客户端都有独立的<code>PlayerController</code>和<code>UI</code></li>
<li>其余与<code>Server</code>同时拥有</li>
</ul>
</li>
</ul>
<h3 id="2-Listen-Server"><a href="#2-Listen-Server" class="headerlink" title="2. Listen Server"></a>2. Listen Server</h3><h4 id="2-1-Replication"><a href="#2-1-Replication" class="headerlink" title="2.1 Replication"></a>2.1 Replication</h4><ul>
<li><strong>说明：</strong><ul>
<li>信息从服务端同步到客户端<code>(单向)</code></li>
<li><code>Actor</code>及其派生类才有<code>Replication</code>的能力</li>
</ul>
</li>
</ul>
<h4 id="2-2-Replication类型"><a href="#2-2-Replication类型" class="headerlink" title="2.2 Replication类型"></a>2.2 Replication类型</h4><ul>
<li><strong>类型：</strong><ol>
<li><code>Actor Replication</code></li>
<li><code>Property Replication</code></li>
<li><code>Component Replication</code></li>
</ol>
</li>
</ul>
<ul>
<li><p>在服务端进行操作：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> (HasAuthority())</span><br><span class="line">&#123;</span><br><span class="line">	TestNum = <span class="number">999.f</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>




</li>
</ul>
<h5 id="2-2-1-Actor-Replication"><a href="#2-2-1-Actor-Replication" class="headerlink" title="2.2.1 Actor Replication"></a>2.2.1 Actor Replication</h5><ul>
<li><strong>两层意义：</strong><ol>
<li>服务端生成，客户端也跟着生成<code>(在服务端生成一个replication对象)</code></li>
<li>当前<code>Actor</code>的所有属性复制，组件复制，RPC的总开关</li>
</ol>
</li>
</ul>
<ul>
<li><p><strong>开启Replication</strong></p>
<ul>
<li><p>蓝图：勾选<code>Replicates</code></p>
</li>
<li><p>C++：在构造函数中实现</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">bReplicates = <span class="literal">true</span>;</span><br><span class="line">SetReplicates(<span class="literal">true</span>);</span><br><span class="line"></span><br><span class="line">其中Set要慢一点</span><br></pre></td></tr></table></figure>




</li>
</ul>
</li>
</ul>
<h5 id="2-2-2-Property-Replication"><a href="#2-2-2-Property-Replication" class="headerlink" title="2.2.2 Property Replication"></a>2.2.2 Property Replication</h5><ul>
<li><p><strong>开启方式：</strong></p>
<ul>
<li><p>前提：<code>Actor Replication</code>是<code>true</code></p>
</li>
<li><p>蓝图：<code>Replication</code>设置为<code>Replicated</code></p>
</li>
<li><p>C++：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">UPROPERTY(Replicated)</span><br><span class="line"><span class="keyword">float</span> TestNum;</span><br></pre></td></tr></table></figure>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;Net/UnrealNetwork.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">AMyActor::GetLifetimeReplicatedProps</span><span class="params">(TArray&lt;FLifetimeProperty&gt;&amp; OutLifetimeProps)</span> <span class="keyword">const</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	Super::GetLifetimeReplicatedProps(OutLifetimeProps);</span><br><span class="line">	</span><br><span class="line">	DOREPLIFETIME(AMyActor, TestNum);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></li>
<li><p><code>AMyActor</code>是需要复制属性的类</p>
</li>
<li><p><code>TestNum</code>是待复制的属性</p>
</li>
</ul>
</li>
</ul>
<h5 id="2-2-3-Rep-Notify"><a href="#2-2-3-Rep-Notify" class="headerlink" title="2.2.3 Rep Notify"></a>2.2.3 Rep Notify</h5><ul>
<li><strong>说明：</strong>变量设为<code>Rep_Notify</code>，当变量发生复制时，<code>服务端</code>和<code>收到的客户端</code>都可以<code>调用</code>一个<code>自定义的函数</code></li>
<li><strong>注意：</strong><code>C++中</code>，自定义函数<code>仅在客户端</code>中调用</li>
</ul>
<ul>
<li><p><strong>设置方式：</strong></p>
<ul>
<li><p>蓝图：<code>Replication</code>设置为<code>RepNotify</code>，会自动生成<code>OnRep_属性()</code>函数</p>
</li>
<li><p>C++：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">UPROPERTY(ReplicatedUsing=OnRep_TestNum, BlueprintReadWrite)</span><br><span class="line"><span class="keyword">int</span> TestNum;</span><br><span class="line"></span><br><span class="line">UFUNCTION()</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">OnRep_TestNum</span><span class="params">()</span></span>;</span><br></pre></td></tr></table></figure>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;MyActor.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;Kismet/KismetSystemLibrary.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;Net/UnrealNetwork.h&quot;</span></span></span><br><span class="line"></span><br><span class="line">AMyActor::AMyActor()</span><br><span class="line">&#123;</span><br><span class="line">	PrimaryActorTick.bCanEverTick = <span class="literal">true</span>;</span><br><span class="line"></span><br><span class="line">	bReplicates = <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">AMyActor::BeginPlay</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	Super::BeginPlay();</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">AMyActor::Tick</span><span class="params">(<span class="keyword">float</span> DeltaTime)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	Super::Tick(DeltaTime);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span> (HasAuthority())</span><br><span class="line">	&#123;</span><br><span class="line">		++TestNum;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">AMyActor::OnRep_TestNum</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">if</span> (HasAuthority())</span><br><span class="line">	&#123;</span><br><span class="line">		UKismetSystemLibrary::PrintString(GetWorld(), FString::Printf(TEXT(<span class="string">&quot;%d&quot;</span>), TestNum));</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">else</span></span><br><span class="line">	&#123;</span><br><span class="line">		UKismetSystemLibrary::PrintString(GetWorld(), FString::Printf(TEXT(<span class="string">&quot;%d&quot;</span>), TestNum));</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">AMyActor::GetLifetimeReplicatedProps</span><span class="params">(TArray&lt;FLifetimeProperty&gt;&amp; OutLifetimeProps)</span> <span class="keyword">const</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	Super::GetLifetimeReplicatedProps(OutLifetimeProps);</span><br><span class="line"></span><br><span class="line">	DOREPLIFETIME(AMyActor, TestNum);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>





</li>
</ul>
</li>
</ul>
<h4 id="2-3-OwnerShip"><a href="#2-3-OwnerShip" class="headerlink" title="2.3 OwnerShip"></a>2.3 OwnerShip</h4><ul>
<li><p><strong>作用：</strong></p>
</li>
<li><p>RPC需要确定哪个客户端将执行于客户端的RPC</p>
</li>
<li><p>Actor复制与连接相关性</p>
</li>
<li><p>在涉及所有者时的Actor属性复制条件</p>
</li>
</ul>
<ul>
<li><strong>说明：</strong><ul>
<li>当 Pawn Actor 被 PlayerController 拥有时，它们的所有者将是它们所拥有的 PlayerController。</li>
<li>在此期间，它们归 PlayerController 的连接所有。</li>
<li>Pawn 仅在同时由 PlayerController 拥有/拥有时由该连接拥有。</li>
<li>因此，一旦 PlayerController 不再拥有 Pawn，Pawn 就不再由连接拥有。</li>
</ul>
</li>
</ul>
<ul>
<li><strong>注意：</strong><ul>
<li>连接所有权对于 RPC 之类的东西很重要，因为当在 Actor 上调用 RPC 函数时，除非 RPC 被标记为多播，否则它需要知道在哪个客户端上执行该 RPC。</li>
<li>它通过查找拥有的连接来确定将 RPC 发送到的连接。</li>
</ul>
</li>
</ul>
<ul>
<li><p><strong>使用：</strong></p>
<ul>
<li><p>蓝图</p>
<ul>
<li>设置<ul>
<li>SpawnActor中又Owner可以引用</li>
<li>SetOwner</li>
</ul>
</li>
<li>改变<ul>
<li>Possess(OnPossess &gt; PossessedBy &gt; SetOwner), UnPossess</li>
</ul>
</li>
<li>获得<ul>
<li>GetOwner</li>
</ul>
</li>
</ul>
</li>
<li><p>C++</p>
<ul>
<li><p>设置</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//SpawnParameters 内可以设置 Onwer</span></span><br><span class="line">GetWorld()-&gt;SpawnActor(Class, <span class="keyword">const</span>* UserTransformPtr, <span class="keyword">const</span> SpawnParameters);</span><br><span class="line">	</span><br><span class="line"><span class="comment">// SetOwner</span></span><br><span class="line">SetOwner(NewOwner);</span><br></pre></td></tr></table></figure></li>
<li><p>获取</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">GetOwner();</span><br></pre></td></tr></table></figure>






</li>
</ul>
</li>
</ul>
</li>
</ul>
<h4 id="2-4-Actor-Role"><a href="#2-4-Actor-Role" class="headerlink" title="2.4 Actor Role"></a>2.4 Actor Role</h4><ul>
<li><strong>分类：</strong><ol>
<li>Authority 权威</li>
<li>Simulated Proxy 模拟代理</li>
<li>Autonomous Proxy 自主代理</li>
</ol>
</li>
</ul>
<ul>
<li><strong>基本结构：</strong>A， B， C <code>A为房主</code><ul>
<li>ServerA：A, B, C <code>Authority</code></li>
<li>ClientB：A, C <code>Simulated</code>, B <code>Autonomous</code></li>
<li>ClentC: A, B <code>Simulated</code>, C <code>Autonomous</code></li>
</ul>
</li>
</ul>
<ul>
<li><strong>说明：</strong>当涉及到复制时，actor 有两个很重要的属性。<code>Role</code>和<code>RemoteRole</code>。</li>
<li><strong>作用：</strong><ul>
<li>谁对演员有权力</li>
<li>演员是否被复制</li>
<li>复制模式</li>
</ul>
</li>
</ul>
<ul>
<li>服务器复制到客户端的条件：<code>Role == ROLE_Authority</code>and <code>RemoteRole == ROLE_SimulatedProxy</code>or <code>ROLE_AutonomousProxy</code></li>
</ul>
<h3 id="3-RPC介绍"><a href="#3-RPC介绍" class="headerlink" title="3. RPC介绍"></a>3. RPC介绍</h3><ul>
<li>类似于函数调用，不过不一定是在本地执行</li>
</ul>
<ul>
<li>可以实现：<ul>
<li>客户端调用，服务端执行</li>
<li>服务端调用，客户端执行</li>
</ul>
</li>
<li>不可以有返回值</li>
<li>默认不可靠（可以设置成Reliable）</li>
</ul>
<h4 id="3-1-RPC设置"><a href="#3-1-RPC设置" class="headerlink" title="3.1 RPC设置"></a>3.1 RPC设置</h4><p><strong>蓝图：</strong></p>
<ul>
<li>CustomEvent 的 Replicates 选项设置为其中一个<ul>
<li>Run On Server</li>
<li>Run On Owning Client</li>
<li>Net MultiCast</li>
</ul>
</li>
<li>要勾选<code>Reliable</code></li>
</ul>
<p><strong>C++：</strong></p>
<ul>
<li>将一个自定义的函数声明为RPC，需要添加反射<code>UFUNCTION()</code><ul>
<li>Server</li>
<li>Client</li>
<li>NetMultiCast</li>
</ul>
</li>
<li>额外添加<code>Reliable</code></li>
</ul>
<h4 id="3-2-RPC要求和注意"><a href="#3-2-RPC要求和注意" class="headerlink" title="3.2 RPC要求和注意"></a>3.2 RPC要求和注意</h4><p>要使 RPC 完全正常运行，需要满足一些要求：</p>
<ul>
<li>它们必须从 Actors 中调用</li>
<li>必须复制 Actor</li>
<li>如果从服务器调用 RPC 以在客户端上执行，则只有实际拥有该 Actor 的客户端将执行该函数</li>
<li>如果从客户端调用 RPC 以在服务器上执行，则客户端必须拥有正在调用 RPC 的 Actor</li>
<li>多播 RPC 是一个例外：<ul>
<li>如果从服务器调用它们，服务器将在本地执行它们以及在所有当前连接的客户端上执行它们</li>
<li>如果从客户端调用，它们只会在本地执行，不会在服务器上执行</li>
<li>目前，我们有一个简单的多播事件限制机制：多播函数在给定 Actor 的网络更新周期内不会复制超过两次。从长远来看，我们希望对此进行改进，并为跨渠道流量管理和节流提供更好的支持</li>
</ul>
</li>
</ul>
<p>​    </p>
<p><strong>从Server调用RPC</strong></p>
<table>
<thead>
<tr>
<th>演员所有权</th>
<th>未复制</th>
<th><code>NetMulticast</code></th>
<th><code>Server</code></th>
<th><code>Client</code></th>
</tr>
</thead>
<tbody><tr>
<td><strong>客户拥有的演员</strong></td>
<td>在服务器上运行</td>
<td>在服务器和所有客户端上运行</td>
<td>在服务器上运行</td>
<td>在演员拥有的客户端上运行</td>
</tr>
<tr>
<td><strong>服务器拥有的演员</strong></td>
<td>在服务器上运行</td>
<td>在服务器和所有客户端上运行</td>
<td>在服务器上运行</td>
<td>在服务器上运行</td>
</tr>
<tr>
<td><strong>无名演员</strong></td>
<td>在服务器上运行</td>
<td>在服务器和所有客户端上运行</td>
<td>在服务器上运行</td>
<td>在服务器上运行</td>
</tr>
</tbody></table>
<p><strong>从Client调用RPC</strong></p>
<table>
<thead>
<tr>
<th>演员所有权</th>
<th>未复制</th>
<th><code>NetMulticast</code></th>
<th><code>Server</code></th>
<th><code>Client</code></th>
</tr>
</thead>
<tbody><tr>
<td><strong>由调用客户端拥有</strong></td>
<td>在调用客户端时运行</td>
<td>在调用客户端时运行</td>
<td>在服务器上运行</td>
<td>在调用客户端时运行</td>
</tr>
<tr>
<td><strong>由不同的客户拥有</strong></td>
<td>在调用客户端时运行</td>
<td>在调用客户端时运行</td>
<td>掉落</td>
<td>在调用客户端时运行</td>
</tr>
<tr>
<td><strong>服务器拥有的演员</strong></td>
<td>在调用客户端时运行</td>
<td>在调用客户端时运行</td>
<td>掉落</td>
<td>在调用客户端时运行</td>
</tr>
<tr>
<td><strong>无名演员</strong></td>
<td>在调用客户端时运行</td>
<td>在调用客户端时运行</td>
<td>掉落</td>
<td>在调用客户端时运行</td>
</tr>
</tbody></table>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">FHang</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://fhangh.gitee.io/article/7dd18469.html">https://fhangh.gitee.io/article/7dd18469.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://fhangh.gitee.io" target="_blank">Element</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/fhangh/tags/UnrealEngine/">UnrealEngine</a></div><div class="post_share"><div class="social-share" data-image="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_26.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/fhangh/article/3fadb38f.html"><img class="prev-cover" data-lazy-src="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_27.jpg" onerror="onerror=null;src='/fhangh/img/404.jpg'"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">UE4联网和多人游戏</div></div></a></div><div class="next-post pull-right"><a href="/fhangh/article/cb9854b2.html"><img class="next-cover" data-lazy-src="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_25.jpg" onerror="onerror=null;src='/fhangh/img/404.jpg'"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">UE4 MySQL插件使用</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/fhangh/article/3fadb38f.html" title="UE4联网和多人游戏"><img class="cover" data-lazy-src="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_27.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-05-26</div><div class="title">UE4联网和多人游戏</div></div></a></div><div><a href="/fhangh/article/cb9854b2.html" title="UE4 MySQL插件使用"><img class="cover" data-lazy-src="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_25.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-03-27</div><div class="title">UE4 MySQL插件使用</div></div></a></div><div><a href="/fhangh/article/605bd1ac.html" title="UE4 MySQL插件开发"><img class="cover" data-lazy-src="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_24.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-03-26</div><div class="title">UE4 MySQL插件开发</div></div></a></div><div><a href="/fhangh/article/80740681.html" title="UE4初始设置及个人使用崩溃记录"><img class="cover" data-lazy-src="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_10.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-03-13</div><div class="title">UE4初始设置及个人使用崩溃记录</div></div></a></div></div></div></div><div class="aside_content" id="aside_content"><div class="card-widget card-info"><div class="card-content"><div class="card-info-avatar is-center"><img class="avatar-img" data-lazy-src="/fhangh/img/fh.png" onerror="this.onerror=null;this.src='/fhangh/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">FHang</div><div class="author-info__description"></div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/fhangh/archives/"><div class="headline">文章</div><div class="length-num">26</div></a></div><div class="card-info-data-item is-center"><a href="/fhangh/tags/"><div class="headline">标签</div><div class="length-num">10</div></a></div><div class="card-info-data-item is-center"><a href="/fhangh/categories/"><div class="headline">分类</div><div class="length-num">4</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/FHangH"><i class="fab fa-github"></i><span>Link To</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/FHangH" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:752972182@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div></div><div class="card-widget card-announcement"><div class="card-content"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">个人学习笔记</div></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="card-content"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#UE4-RPC"><span class="toc-number">1.</span> <span class="toc-text">UE4 RPC</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-RPC-%E6%9E%B6%E6%9E%84"><span class="toc-number">1.0.1.</span> <span class="toc-text">1. RPC 架构</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-1-%E6%9E%B6%E6%9E%84%E7%AE%80%E4%BB%8B"><span class="toc-number">1.0.1.1.</span> <span class="toc-text">1.1 架构简介</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2-%E5%9F%BA%E6%9C%ACGamePlay%E7%BB%93%E6%9E%84"><span class="toc-number">1.0.1.2.</span> <span class="toc-text">1.2 基本GamePlay结构</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-Listen-Server"><span class="toc-number">1.0.2.</span> <span class="toc-text">2. Listen Server</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#2-1-Replication"><span class="toc-number">1.0.2.1.</span> <span class="toc-text">2.1 Replication</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-Replication%E7%B1%BB%E5%9E%8B"><span class="toc-number">1.0.2.2.</span> <span class="toc-text">2.2 Replication类型</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#2-2-1-Actor-Replication"><span class="toc-number">1.0.2.2.1.</span> <span class="toc-text">2.2.1 Actor Replication</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2-2-2-Property-Replication"><span class="toc-number">1.0.2.2.2.</span> <span class="toc-text">2.2.2 Property Replication</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2-2-3-Rep-Notify"><span class="toc-number">1.0.2.2.3.</span> <span class="toc-text">2.2.3 Rep Notify</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-3-OwnerShip"><span class="toc-number">1.0.2.3.</span> <span class="toc-text">2.3 OwnerShip</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-4-Actor-Role"><span class="toc-number">1.0.2.4.</span> <span class="toc-text">2.4 Actor Role</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-RPC%E4%BB%8B%E7%BB%8D"><span class="toc-number">1.0.3.</span> <span class="toc-text">3. RPC介绍</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#3-1-RPC%E8%AE%BE%E7%BD%AE"><span class="toc-number">1.0.3.1.</span> <span class="toc-text">3.1 RPC设置</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2-RPC%E8%A6%81%E6%B1%82%E5%92%8C%E6%B3%A8%E6%84%8F"><span class="toc-number">1.0.3.2.</span> <span class="toc-text">3.2 RPC要求和注意</span></a></li></ol></li></ol></li></ol></li></ol></div></div></div><div class="card-widget card-recent-post"><div class="card-content"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/fhangh/article/3fadb38f.html" title="UE4联网和多人游戏"><img data-lazy-src="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_27.jpg" onerror="this.onerror=null;this.src='/fhangh/img/404.jpg'" alt="UE4联网和多人游戏"/></a><div class="content"><a class="title" href="/fhangh/article/3fadb38f.html" title="UE4联网和多人游戏">UE4联网和多人游戏</a><time datetime="2022-05-26T14:04:45.432Z" title="发表于 2022-05-26 22:04:45">2022-05-26</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/fhangh/article/7dd18469.html" title="UE4 RPC"><img data-lazy-src="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_26.jpg" onerror="this.onerror=null;this.src='/fhangh/img/404.jpg'" alt="UE4 RPC"/></a><div class="content"><a class="title" href="/fhangh/article/7dd18469.html" title="UE4 RPC">UE4 RPC</a><time datetime="2022-05-19T04:30:00.826Z" title="发表于 2022-05-19 12:30:00">2022-05-19</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/fhangh/article/cb9854b2.html" title="UE4 MySQL插件使用"><img data-lazy-src="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_25.jpg" onerror="this.onerror=null;this.src='/fhangh/img/404.jpg'" alt="UE4 MySQL插件使用"/></a><div class="content"><a class="title" href="/fhangh/article/cb9854b2.html" title="UE4 MySQL插件使用">UE4 MySQL插件使用</a><time datetime="2022-03-27T06:49:30.840Z" title="发表于 2022-03-27 14:49:30">2022-03-27</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/fhangh/article/605bd1ac.html" title="UE4 MySQL插件开发"><img data-lazy-src="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_24.jpg" onerror="this.onerror=null;this.src='/fhangh/img/404.jpg'" alt="UE4 MySQL插件开发"/></a><div class="content"><a class="title" href="/fhangh/article/605bd1ac.html" title="UE4 MySQL插件开发">UE4 MySQL插件开发</a><time datetime="2022-03-26T07:56:25.807Z" title="发表于 2022-03-26 15:56:25">2022-03-26</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/fhangh/article/f7ede91d.html" title="Java基础"><img data-lazy-src="https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img_mini/postImg_19.jpg" onerror="this.onerror=null;this.src='/fhangh/img/404.jpg'" alt="Java基础"/></a><div class="content"><a class="title" href="/fhangh/article/f7ede91d.html" title="Java基础">Java基础</a><time datetime="2021-12-12T07:47:44.788Z" title="发表于 2021-12-12 15:47:44">2021-12-12</time></div></div></div></div></div></div></div></main><footer id="footer" style="background-image: url(https://cdn.jsdelivr.net/gh/FHangH/FHangBlogCDN/Post_Img/postImg_26.jpg)"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By FHang</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"><div id="local-hits"></div><div id="local-stats"><div class="local-search-stats__hr" id="hr"><span>由</span> <a target="_blank" rel="noopener" href="https://github.com/wzpan/hexo-generator-search" style="color:#49B1F5;">hexo-generator-search</a>
 <span>提供支持</span></div></div></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script src="/fhangh/js/utils.js"></script><script src="/fhangh/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/fhangh/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',()=> {preloader.endLoading()})</script><div class="js-pjax"><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="true"></script></div></body></html>